﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using Toenda.Foundation.Windows.Forms;

namespace WFTestApplication {
	public partial class Form1 : Form, IMessageFilter {
		VirtualConsole my_console;

		public Form1() {
			InitializeComponent();
			Application.AddMessageFilter(this);

			tStrip.Renderer = new WindowsVistaRenderer();

			//fileSystemTreeView1.Load(@"C:\Users\vandango\Desktop\svw");
		}

		private void button1_Click(object sender, EventArgs e) {
			List<FileToCopy> files = new List<FileToCopy>();

			//files.Add(
			//    new FileToCopy {
			//        SourceFilename = @"C:\Users\vandango\Desktop\SetupAnyDVD6609.exe",
			//        TargetFilename = @"C:\Users\vandango\Desktop\__SetupAnyDVD6609.exe" 
			//    }
			//);

			files.Add(
				new FileToCopy {
					SourceFilename = @"C:\Users\vandango\Desktop\fc_setup_.zip",
					TargetFilename = @"C:\Users\vandango\Desktop\__fc_setup_.zip"
				}
			);

			FileCopyForm form = new FileCopyForm(
				files, 
				false
			);

			if(form.ShowDialog(this) == DialogResult.OK) {
				StaticWindows.ErrorBox("fertich...");
			}
			else {
				StaticWindows.ErrorBox("abbruch...");
			}
		}

		private void Form1_Shown(object sender, EventArgs e) {
			this.my_console = new VirtualConsole(this);
			this.my_console.SetVisibility(false);
		}

		public bool PreFilterMessage(ref Message msg) {
			int WM_KEYDOWN = 0x100;
			if(msg.Msg == WM_KEYDOWN) {
				if(msg.WParam.ToString() == "220") {
					// Taste ^
					my_console.SetVisibility(!my_console.GetVisibility());
					return true;
				}
				else {
					// Erlaube das scrollen in der Konsole nur wenn die Konsole sichtbar ist
					if(my_console.GetVisibility() == true) {
						if(msg.WParam.ToString() == "33") {
							// Bildhoch
							my_console.Scroll_Up();
							return true;
						}
						else if(msg.WParam.ToString() == "34") {
							// Bildrunter
							my_console.Scroll_Down();
							return true;
						}
					}
				}
			}

			return false;
		}
	}
}
